﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

public partial class View_login : System.Web.UI.Page
{
    public string LoginResult = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginResult = string.Empty;
        Label1.Text = System.DateTime.Now.ToString();
    }

    protected void btn_login_onclick(object sender, EventArgs e)
    { 
        MISAPP.Classify.Service.Utility utility = new MISAPP.Classify.Service.Utility();
        List<string> result = utility.Login(txt_login.Text, txt_pw.Text
            ,Request.UserHostAddress.ToString());
        if (result.Count > 2)
        {
            FormsAuthentication.SetAuthCookie(txt_login.Text, false);
            FormsAuthentication.RedirectFromLoginPage(txt_login.Text, false);
            //取回來的結果先存入到session中，第二個位置是，目前使用者的等級。
            Session["result"] = result; 
        }
        else
        { LoginResult = "登入錯誤，請檢查ID 或密碼！！"; }
    }
}
